<?php
// 本类由系统自动生成，仅供测试用途
class AlikzAction extends Action {

	
	

    //公版
    public function query(){
    	header("Content-Type:text/html; charset=utf-8");
    	$environment=D('Environment');$usr=D('Usr');$alithrd=D('Alithrd');
      $arr_usross=$environment->setenvironment(MODULE_NAME);$usross=$arr_usross['data'];

     
      //先去数据库看看是否有存线程，如果有，就看看该线程是否在跑
      $arr_thrdo=$alithrd->getthrdo();$thrdo=$arr_thrdo['data'];
      if($thrdo['thrdnm']){
        $arr_rslt=$alithrd->checkthrdbythrdnm($thrdo['thrdnm']);$rslt=$arr_rslt['data'];
        $this->assign('thrdstat',$rslt);
      }


      $this->assign('ttl','支付宝软件控制');
      $this->display('query');
  
    }

    public function dostart(){
      header("Content-Type:text/html; charset=utf-8");
      $alithrd=D('Alithrd');

      $arr_dt=$alithrd->start();$dt=$arr_dt['data'];
      $data['dt']=$dt;

      $this->ajaxReturn($data,'json');
      
    }
    
    public function dostop(){
      header("Content-Type:text/html; charset=utf-8");
      $alithrd=D('Alithrd');

      $arr_rslt=$alithrd->stop();$rslt=$arr_rslt['data'];
      $data['rslt']=$rslt;

      $this->ajaxReturn($data,'json');
      
    }

    public function dogetthrdstat(){
      header("Content-Type:text/html; charset=utf-8");
      $alithrd=D('Alithrd');      

      $arr_thrdo=$alithrd->getthrdo();$thrdo=$arr_thrdo['data'];
      $arr_stat=$alithrd->getthrdstat($thrdo['thrdnm']);$stat=$arr_stat['data'];

      $data['stat']=$stat;

      $this->ajaxReturn($data,'json');
      
    }

    public function gotoopenthrd(){
      header("Content-Type:text/html; charset=utf-8");
       $this->display('gotoopenthrd');
      
    }
    
    public function showsqlresult(){
      header("Content-Type:text/html; charset=utf-8");

      $sql=D('Sql');

      $environment=D('Environment');
      $arr_usross=$environment->setenvironment(MODULE_NAME);$usross=$arr_usross['data'];

      $sqltxt=gp()['sqltxt'];

      $arr_result=$sql->exesql($sqltxt);$result=$arr_result['data'];
      
      $this->assign('result',$result);
      $this->assign('ttl','结果');
      $this->display('showsqlresult');
  
    }

    public function showsqlresult_table(){
      header("Content-Type:text/html; charset=utf-8");
      $sql=D('Sql');

      $environment=D('Environment');
      $arr_usross=$environment->setenvironment(MODULE_NAME);$usross=$arr_usross['data'];

      $sqltxt=gp()['sqltxt'];

      $arr_result=$sql->exesql($sqltxt);$result=$arr_result['data'];
      
      $this->assign('result',$result);
      $this->assign('ttl','结果_表格');
      $this->display('showsqlresult_table');
  
    }

}